<template>
  <div>
    <el-table :data="[form]" border style="width: 100%">
      <el-table-column
        prop="title"
        label="投诉标题"
        width="180"
      ></el-table-column>
      <el-table-column label="投诉信息" width="180">
        <span v-html="form.content"></span
      ></el-table-column>
      <el-table-column prop="createTime" label="创建时间"></el-table-column>
      <el-table-column prop="fileName" label="附件">
        <template slot-scope="scope">
          <el-link
            type="primary"
            @click="download(scope.row.filePath)"
            underline
          >
            {{ scope.row.fileName }}
          </el-link>
        </template>
      </el-table-column>
      <el-table-column prop="statusName" label="处理状态"></el-table-column>
      <el-table-column prop="remark" label="处理结果"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getById } from "./a";
import { download } from "../../utils/neu";

export default {
  name: "detail",

  created() {
    const { id } = this.$route.query;
    this.id = id;
    getById(id).then(res => {
      this.form = res.data;
    });
  },
  methods: {
    downloadFile(filePath, fileName) {
      // 创建隐藏的 a 标签
      const link = document.createElement("a");
      link.href = filePath;
      link.download = fileName; // 设置下载的文件名
      link.style.display = "none";
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    }
  },
  data() {
    return {
      id: "",
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄"
        }
      ],
      form: {}
    };
  },

  mounted() {}
};
</script>

<style lang="scss" scoped></style>
